// pages/user/like.js
import { UserAuth } from "../../model/user-auth";
import Dialog from '@vant/weapp/dialog/dialog';
Page({

    /**
     * 页面的初始数据
     */
    data: {
        one: [],
        two: [],
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        wx.showLoading({
            title: '加载中',
        });
        this.getUserAuthLike();
    },
    /**
     * 获取喜欢列表
     */
    async getUserAuthLike() {
        const res = await UserAuth.getUserAuthLike({});
        this.setData({
            one: res.one,
            two: res.two,
        });
        wx.hideLoading();
    },
    openWin(e) {
        wx.navigateTo({
            url: '../blind_date/details?id='+e.currentTarget.dataset.id,
        })
    },
    /**
     * 弹出删除
     */
    onClose(event) {
        // const { position, instance } = event.detail;
        const self = this;
        Dialog.confirm({
            message: '确定删除吗？',
        }).then(async () => {
            const res = await  self.likeDel(event.currentTarget.dataset.id);
            if(res) {
                // instance.close();
                self.getUserAuthLike();
            }
        });
    },
    async likeDel(user_auth_id) {
        const res = await UserAuth.addLike(user_auth_id);
        return res;
    }
})